home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbmci / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  6.1 KB  |  180 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Play Multimedia Files Sample"
  5.    ClientHeight    =   555
  6.    ClientLeft      =   1530
  7.    ClientTop       =   2535
  8.    ClientWidth     =   7365
  9.    Height          =   1245
  10.    Left            =   1470
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   555
  13.    ScaleWidth      =   7365
  14.    Top             =   1905
  15.    Width           =   7485
  16.    Begin CommandButton cmdPlayAVI 
  17.       Caption         =   "Play AVIVideo"
  18.       Height          =   495
  19.       Left            =   3720
  20.       TabIndex        =   2
  21.       Top             =   1440
  22.       Width           =   1455
  23.    End
  24.    Begin CommonDialog CMDialog1 
  25.       Left            =   6240
  26.       Top             =   600
  27.    End
  28.    Begin CommandButton cmdGenericPlay 
  29.       Caption         =   "Generic Play"
  30.       Height          =   495
  31.       Left            =   360
  32.       TabIndex        =   0
  33.       Top             =   1440
  34.       Width           =   1455
  35.    End
  36.    Begin Label Label2 
  37.       BackColor       =   &H00C0C0C0&
  38.       Caption         =   "Play a WAV file or an AVI file in a default window:"
  39.       Height          =   495
  40.       Left            =   120
  41.       TabIndex        =   3
  42.       Top             =   960
  43.       Width           =   2295
  44.    End
  45.    Begin Label Label3 
  46.       BackColor       =   &H00C0C0C0&
  47.       Caption         =   "Play an AVI file in a custom overlapped window:"
  48.       Height          =   495
  49.       Left            =   3240
  50.       TabIndex        =   4
  51.       Top             =   960
  52.       Width           =   2415
  53.    End
  54.    Begin Label Label1 
  55.       BackColor       =   &H00C0C0C0&
  56.       Caption         =   "Select Open from the File menu to open a multimedia file."
  57.       Height          =   255
  58.       Left            =   120
  59.       TabIndex        =   1
  60.       Top             =   120
  61.       Width           =   5415
  62.    End
  63.    Begin Menu mnuFile 
  64.       Caption         =   "&File"
  65.       Begin Menu mnuFile_Open 
  66.          Caption         =   "&Open"
  67.       End
  68.    End
  69.    Begin Menu mnuVBX 
  70.       Caption         =   "MCI.VBX"
  71.       Begin Menu mnuVBX_Standard 
  72.          Caption         =   "Standard Controls..."
  73.       End
  74.    End
  75.    Begin Menu mnuHelp 
  76.       Caption         =   "&Help"
  77.       Begin Menu mnuAbout 
  78.          Caption         =   "&About"
  79.          Shortcut        =   {F1}
  80.       End
  81.    End
  82. Sub cmdGenericPlay_Click ()
  83.     Dim ReturnString As String * 1024
  84.     Dim ErrorString As String * 1024
  85.     result& = mciSendString("open " & Filename & " alias file", ReturnString, 1024, 0)
  86.     If Not result& = 0 Then
  87.     errormsg% = mciGetErrorString(result&, ErrorString, 1024)
  88.     MsgBox ErrorString, 0, "Error"
  89.     Exit Sub
  90.     End If
  91.     result& = mciSendString("play file wait", ReturnString, 1024, 0)
  92.     If Not result& = 0 Then
  93.     errormsg% = mciGetErrorString(result&, ErrorString, 1024)
  94.     MsgBox ErrorString, 0, "Error"
  95.     End If
  96.     result& = mciSendString("close file", ReturnString, 1024, 0)
  97.     If Not result& = 0 Then
  98.     errormsg% = mciGetErrorString(result&, ErrorString, 1024)
  99.     MsgBox ErrorString, 0, "Error"
  100.     End If
  101. End Sub
  102. Sub cmdmciSendString_Click ()
  103.     Dim ReturnString As String * 1024
  104.     Dim ErrorString As String * 1024
  105.     result& = mciSendString("open " & Filename & " alias file", ReturnString, 1024, 0)
  106.     If Not result& = 0 Then
  107.     errormsg% = mciGetErrorString(result&, ErrorString, 1024)
  108.     MsgBox ErrorString, 0, "Error"
  109.     Exit Sub
  110.     End If
  111.     result& = mciSendString("play file wait", ReturnString, 1024, 0)
  112.     If Not result& = 0 Then
  113.     errormsg% = mciGetErrorString(result&, ErrorString, 1024)
  114.     MsgBox ErrorString, 0, "Error"
  115.     End If
  116.     result& = mciSendString("close file", ReturnString, 1024, 0)
  117.     If Not result& = 0 Then
  118.     errormsg% = mciGetErrorString(result&, ErrorString, 1024)
  119.     MsgBox ErrorString, 0, "Error"
  120.     End If
  121. End Sub
  122. Sub cmdPlayAVI_Click ()
  123.    Dim CmdStr As String
  124.    Dim ret As Integer
  125.    Dim ErrorString As String * 1024
  126.    Dim ReturnString As String * 1024
  127.    '*** This will open the AVIVideo and create an overlapped window on the
  128.    '*** form where the video will display. Animation is the device_id.
  129.    CmdStr = ("open " + Filename + " type AVIVideo alias Animation parent " + LTrim$(Str$(Form1.hWnd)) + " style overlapped")
  130.    ret = mciSendString(CmdStr, ReturnString, 1024, 0)
  131.    If Not ret = 0 Then
  132.     errormsg% = mciGetErrorString(ret, ErrorString, 1024)
  133.     MsgBox ErrorString, 0, "Error"
  134.     Exit Sub
  135.    End If
  136.    '*** Put the window near the top left corner of the screen
  137.    ret = mciSendString("put Animation window at 10 10 200 200", ReturnString, 1024, 0)
  138.    If Not ret = 0 Then
  139.     errormsg% = mciGetErrorString(ret, ErrorString, 1024)
  140.     MsgBox ErrorString, 0, "Error"
  141.    End If
  142.    '*** The wait tells the MCI command to complete before returning
  143.    '*** control to the application.
  144.    ret = mciSendString("play Animation wait", ReturnString, 1024, 0)
  145.    If Not ret = 0 Then
  146.     errormsg% = mciGetErrorString(ret, ErrorString, 1024)
  147.     MsgBox ErrorString, 0, "Error"
  148.    End If
  149.    '*** Close windows so they don't crash when you exit the application.
  150.    ret = mciSendString("close Animation", ReturnString, 1024, 0)
  151.    If Not ret = 0 Then
  152.     errormsg% = mciGetErrorString(ret, ErrorString, 1024)
  153.     MsgBox ErrorString, 0, "Error"
  154.    End If
  155. End Sub
  156. Sub mnuAbout_Click ()
  157.     frmAbout.Show
  158. End Sub
  159. Sub mnuFile_Open_Click ()
  160.     ' Display the File Open... dialog.
  161.     OpenDlg.CMDialog1.FilterIndex = 1
  162.     OpenDlg.CMDialog1.Filter = "AVI Files (*.avi)|*.avi|Wave Files (*.wav)|*.wav|All Files (*.*)|*.*"
  163.     OpenDlg.CMDialog1.Flags = OFN_READONLY Or OFN_FILEMUSTEXIST
  164.     OpenDlg.CMDialog1.CancelError = True
  165.     OpenDlg.CMDialog1.Filename = ""
  166.     On Error Resume Next
  167.     OpenDlg.CMDialog1.Action = 1
  168.     If Err <> 0 Then
  169.     ' No file selected from the "Open File..." dialog.
  170.     Exit Sub
  171.     End If
  172.     'Assign the selected file to the global variable, Filename
  173.     Filename = OpenDlg.CMDialog1.Filename
  174.     Label1.Caption = Filename
  175.     Form1.Height = 2800
  176. End Sub
  177. Sub mnuVBX_Standard_Click ()
  178.     frmMCIVBX.Show 1
  179. End Sub
  180.